package cate.game.pvp.championrace.data;

import cate.game.role.RoleSnapshot;
import cate.game.role.show.frame.HeadFrameVO;
import cate.game.role.show.icon.HeadIconVO;
import cate.game.util.GameKit;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.ToString;
import org.springframework.data.annotation.Id;

@ToString
@Data
public class ChampionRaceRedPacketRecord {

    @JsonIgnore
    @Id
    private String id = GameKit.uid();

    private ChampionRaceSpec spec;

    private String uid;
    private String name;
    private int level;
    private HeadFrameVO headFrame;
    private HeadIconVO headIcon;
    private int srvIdOrigin;
    private long rpCoins;
    private long recordTime;

    public static ChampionRaceRedPacketRecord of(ChampionRaceSpec spec, RoleSnapshot snapshot, long rpCoins) {
        return of(
                spec,
                snapshot.base.uid,
                snapshot.base.name,
                snapshot.base.level,
                snapshot.base.headFrame,
                snapshot.base.headIcon,
                snapshot.base.srvIdOrigin,
                rpCoins,
                System.currentTimeMillis()
        );
    }

    public static ChampionRaceRedPacketRecord of(ChampionRaceSpec spec,
                                                 String uid,
                                                 String name,
                                                 int level,
                                                 HeadFrameVO headFrame,
                                                 HeadIconVO headIcon,
                                                 int srvIdOrigin,
                                                 long rpCoins,
                                                 long recordTime) {
        ChampionRaceRedPacketRecord rpRd = new ChampionRaceRedPacketRecord();
        rpRd.setSpec(spec);
        rpRd.setUid(uid);
        rpRd.setName(name);
        rpRd.setLevel(level);
        rpRd.setHeadFrame(headFrame);
        rpRd.setHeadIcon(headIcon);
        rpRd.setSrvIdOrigin(srvIdOrigin);
        rpRd.setRpCoins(rpCoins);
        rpRd.setRecordTime(recordTime);
        return rpRd;
    }

    @JsonIgnore
    public String getIndexedKey() {
        return getId();
    }
}
